-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter out $EntriesMappings class for Kotlin's 1.9 feature 'Enum entries' #144
Conversation
…ies' Kotlin compiler generates synthetic class holding EnumEntries starting from 1.9. This change filters out such classes from the API dump.
While the change is trivial, I don't see a way to test it easily. |
Updating Kotlin to 1.9.0-Beta will do the trick. |
Changed config to make testing of Enum.entries possible. Enum.entries require stdlib >= 1.8.20. Exclusion of stdlib artifacts is only required when Gradle's Kotlin version is higher than the project's one.
Updated to |
ping |
@@ -40,6 +41,7 @@ fun ClassNode.isLocal() = outerMethod != null | |||
fun ClassNode.isInner() = innerClassNode != null | |||
fun ClassNode.isWhenMappings() = isSynthetic(access) && name.endsWith("\$WhenMappings") | |||
fun ClassNode.isSyntheticAnnotationClass() = isSynthetic(access) && name.contains("\$annotationImpl\$") | |||
fun ClassNode.isEnumEntriesMappings() = isSynthetic(access) && name.endsWith("\$EntriesMappings") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are currently no tests that check this behaviour.
You'll need when
over old Kotlin enum (unlikely it's easy to get one in the robust manner) or any Java one in the code to force $EntriesMapping
appearance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing to this! Seems like IDE cached something wrong, so when I validated the test without ClassNode.isEnumEntriesMappings
EntriesMapping
was there despite the fact that Enum
is a "new" enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries.
There is something suspicious happening:
- IDE highlights
EnumClass.entries
as available only since API version 1.8 (red code,[UNSUPPORTED_FEATURE]
) even though you clearly set it up - For clean builds, everything works as expected
- For incremental builds (run all tests, change something in
entries.kt
), mappings start being generated even thoughentries
member is present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll proceed with the issue further
…eature 'Enum entries' * Filter out $EntriesMappings class for Kotlin's 1.9 feature 'Enum entries' Kotlin compiler generates synthetic class holding EnumEntries starting from 1.9. This change filters out such classes from the API dump. * Upgrade a Kotlin version and remove stdlib exclusion Changed config to make testing of Enum.entries possible. Enum.entries require stdlib >= 1.8.20. Exclusion of stdlib artifacts is only required when Gradle's Kotlin version is higher than the project's one. Fixes Kotlin/binary-compatibility-validator#141 Pull request Kotlin/binary-compatibility-validator#144
Kotlin compiler generates synthetic class holding EnumEntries starting from 1.9. This change filters out such classes from the API dump.
Closes #141